<script type="text/javascript">
$(function () {
	var url = '${contextPath}script/inv/invOrderInfo.js';
	$.ajax({url:url, dataType:'script', cache:true,
		success: function(){
			
		}
	});
});
</script>

<#import "/freemarker/modeltype.ftl" as mt>
<#import "/freemarker/modeltype_entity.ftl" as mte>
<div>
	<h3 class="title"><i class="fontello-icon-th-list-1"></i> 编辑订单信息</h3>
</div>
<div class="widget" >
	<div class="widget-content">
		<form id="editForm">
			<table style="width:40%;" class="table table-bordered animate2 fadeInUp">
			<input type="hidden" id="code" name="code" value="${(invOrderInfo.code)!''}" />
			<#if invOrderInfo??>
				<tr>
					<td>订单编号</td>
					<td>
						${(invOrderInfo.dn)!''}
					</td>
				</tr>
			</#if>
				<tr>
					<td>往来单位</td>
					<td>
						<div class="input-group">
							<span class="btn-group">
								<input  name="bn" id="bn" value="${(invOrderInfo.bn)!''}" size="16" type="text" readonly="readonly" style="width: 120px;"/>
								<input type="hidden" name="bc" id="bc" value="${(invOrderInfo.bc)!''}"/>
								<button class="btn btn-primary" type="button" title="选择单位" onclick="javascript: selectBn_invOrderInfo($('#bc').attr('id'), $('#bn').attr('id'));"><i class="icon-search"></i></button>
								<button class="btn btn-danger" type="button" title="去除" onclick="javascript: $('#bc').val(''); $('#bn').val('');"><i class="icon-remove"></i></button>
							</span>
						</div>
					</td>
				</tr>
				</tr>
				<tr>
					<td>订单类型</td>
					<td>
						<select id="type" name="type">
						<#if ((invOrderInfo.type)?? && invOrderInfo.type = 1)>
							<option value="1" selected="selected">进货订单</option>
							<option value="2">销货订单</option>
						<#elseif ((invOrderInfo.type)?? && invOrderInfo.type = 2)>
							<option value="2" selected="selected">销货订单</option>
							<option value="1" >进货订单</option>
						<#else>
							<option value="1">进货订单</option>
							<option value="2">销货订单</option>
						</#if>
						</select>
					</td>
				</tr>
			</table>
			<table style="width:40%;" class="table table-bordered animate2 fadeInUp">
				<thead>
					<tr>
						<th style="text-align:center;">商品名称<a href="javascript:;" onclick="javascript:add_invOrderInfo();" style="margin-left: 10px">[添加空白行]</a></th>
						<th style="text-align:center;">单价</th>
						<th style="text-align:center;">数量</th>
						<th style="width:32px;">操作</th>
					</tr>
				</thead>
				<tbody id="ListBody">
				<#assign i = 0 />
					<#if ((invOrderInfo.itemList)?? && invOrderInfo.itemList?size > 0)>
					<#list invOrderInfo.itemList as item>
					<tr class="rep">
						<td>
							<div class="input-append">
								<input  name="itemList[${i}].cname" id="cname_${i}" value="${(item.cname)!''}" class="cname" type="text" style="width: 150px" readonly/>
								<button class="btn btn-xs btn-primary" type="button" title="选择商品" pib="${i}" onclick="javascript:selectCn_invOrderInfo($(this));"><i class="icon-search"></i></button>
								<input type="hidden" name="itemList[${i}].cc" id="cc_${i}" value="${(item.cc)!''}" class="cc"/>
							</div>
						</td>
						<td><input class="price" id="price_${i}" type="text" name="itemList[${i}].price" value="${(item.price)!''}" style="width:100px;"/></td>
						<td><input class="count" id="count_${i}" type="text" name="itemList[${i}].count" value="${(item.count)!''}" style="width:100px;"/></td>
						<td style="text-align:center;"><a class="btn btn-danger" href="javascript:;" onclick="javascript:delete_invOrderInfo($(this));"><i class="icon-remove"></i></a></td>
					</tr>
					<#assign i = i + 1/></#list><#else>
					<tr class="rep">
						<td>
							<div class="input-append">
								<input  name="itemList[${i}].cname" id="cname_${i}" class="cname" type="text" style="width: 150px" readonly/>
								<button class="btn btn-xs btn-primary" type="button" pib="${i}" title="选择商品" onclick="javascript:selectCn_invOrderInfo($(this));"><i class="icon-search"></i></button>
								<input type="hidden" id="cc_${i}" name="itemList[${i}].cc" class="cc"/>
							</div>
						</td>
						<td><input class="price" type="text" id="price_${i}" name="itemList[${i}].price" style="width:100px;"/></td>
						<td><input class="count" type="text" id="count_${i}" name="itemList[${i}].count" style="width:100px;"/></td>
						<td style="text-align:center;"><a class="btn btn-danger" href="javascript:;" onclick="javascript:delete_invOrderInfo($(this));"><i class="icon-remove"></i></a></td>
					</tr>
					<#assign i = i + 1/></#if>
				</tbody>
				<tr>
					<td colspan="5" style="text-align: center;">
						<a href="javascript:;" class="btn btn-info" onclick="javascript: save_invOrderInfo(); return false;"><i class="icon-save"></i>保存</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						<a href="javascript:;" class="btn btn-info" onclick="javascript: saveIn_invOrderInfo(); return false;"><i class="icon-save"></i>保存并入库</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						<a href="javascript:;" class="btn btn-primary" onclick="javascript: sys_load_handle('invOrderInfo');"><i class="fontello-icon-block"></i>取消</a>
					</td>
				</tr>
			</table>
		</form>
	</div>
</div>


<input type="hidden" id="index" value="${i}" />
<table id="tempTable" style="display: none;">
	<tr class="rep">
		<td>
			<div class="input-append">
				<input class="cname" type="text" readonly style="width: 150px;"/>
				<button class="btn btn-xs btn-primary" type="button" onclick="javascript:selectCn_invOrderInfo($(this));return false;"><i class="icon-search"></i></button>
				<input class="cc" type="hidden" />
			</div>
		</td>
		<td><input class="price" type="text" style="width:100px;"/></td>
		<td><input class="count" type="text" style="width:100px;"/></td>
		<td style="text-align:center;"><a class="btn btn-danger" href="javascript:;" onclick="javascript:delete_invOrderInfo($(this));"><i class="icon-remove"></i></a></td>
	</tr>
</table>